﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Windows.Threading;

namespace Dashboard
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    /// 
    public partial class MainWindow : Window
    {
        //
        bool CheckIsOnlyOneInstanceRunning()
        {
            Process current = Process.GetCurrentProcess();
            Process[] processed = Process.GetProcessesByName(current.ProcessName);

            if (processed.Count() > 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public MainWindow()
        {
            if (CheckIsOnlyOneInstanceRunning())
            {
                MessageBox.Show("there is already an instance running in the system!");
                this.Close();
                return;
            }
            TaskManage.Initial();
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            pagecontentcontrol.Content = LogView.GetLogView();       
        }

        private void TaskButton_Click(object sender, RoutedEventArgs e)
        {
            pagecontentcontrol.Content = TaskView.GetTaskView();
        }

    }

}
